<script type="text/javascript">
function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
</script>
{% extends 'base.html' %}
{% block title %}  - Manage Basket {% endblock %}
{% block onload %}
onload="document.getElementById('new_basket').focus();"
{% endblock %}
{% block content %}

 
<script>
	function check_bas(bas_form){
		if (bas_form.new_basket.value == ""){
			alert("Please input a basket name!");
			return false;
		}

		return true;
	}

	function get_bas_video(videos){
		var i_html = "<table width=\"270\"><tr><td colspan=\"2\"><b>Videos</b><br/></td></tr>";
		for (i=0;i<videos.length/3;i++){
			if (videos[i*3]!='0'){
				i_html += "<tr><td><a href='/video/"+ videos[i*3] +"/'><img src='/site_media/img/film.gif'/> "  + videos[i*3+1] 
					+" </a> </td><td align=\"center\" width=\"40\"><a onmousedown='return confirm(\"Do you want to remove the video from the basket?\");' href='/user/basket/video/delete/" +
					videos[i*3+2] + "/'> <img src='/site_media/img/trash.gif'/></a><br/></td></tr>"
			}
			
			document.getElementById('tags').innerHTML = i_html;
		}
		
		return false;
	}
</script>

<div id="content" style="position:absolute; top:20px; left:0px; width:610px; height:540; background-color: #1A1A1A; layer-background-color: #1A1A1A;">
<table width="610"><tr><td>
<p><span style="font-size:14px;color:#CCC"> Manage baskets</span></p>
</td></tr></table>

<div style="word-wrap:break-word;position:absolute;left:0px;
	 OVERFLOW:auto;overflow-x:hidden;WIDTH:300px;HEIGHT:500px;
	 border:1px solid #7e7d68;top:40px;
	 scrollbar-face-color: #222222; scrollbar-highlight-color: #FFFFFF;
	 scrollbar-3dlight-color: #222222; scrollbar-shadow-color: #FFFFFF;
	 scrollbar-darkshadow-color: #222222; scrollbar-track-color: #222222;
	 scrollbar-arrow-color: #222222">
	<div style="position:relative;left:5px;top:5px;">

        <table width="270">
        <tr>
        <td width="150" colspan="2">
            <b>Baskets</b><br/>
        </td>
        </tr>   
        <form action="/user/basket/new/" method="post" onsubmit="return check_bas(this);">
        <tr>
        <td>
		<input type="text" name="new_basket" id="new_basket"/>
        </td>
        <td align="center" width="40">
		<input type="submit" value="Add" />
    	</td>
    	</tr>
        </form>
 
		{% for bas in dicts.items %}

        <tr>
		<td>		
		<a href="#" title="Open basket" onmousedown="get_bas_video([{% for x in bas.1 %}'{{x.film.id}}','{{x.film.text}}','{{x.id}}',{% endfor %} '0']);MM_showHideLayers('tags','','show')">{{bas.0.name}}</a>
        </td>
		<td align="center">
		<a href="/user/basket/delete/{{bas.0.id}}/" title="Delete basket" onclick="return confirm('Do you want to delete the basket : {{bas.0.name}}?');">
			<img src="/site_media/img/trash.gif"/>
		</a><br/>
        </td></tr>
        {% endfor %}


        </table>
	</div>
</div>


<div style="word-wrap:break-word; position:absolute; left:308px; top:40px; OVERFLOW:auto; overflow-x:hidden; WIDTH: 300px; HEIGHT: 500px; border:1px solid #7e7d68; scrollbar-face-color: #222222; scrollbar-highlight-color: #FFFFFF; scrollbar-3dlight-color: #222222; scrollbar-shadow-color: #FFFFFF; scrollbar-darkshadow-color: #222222; scrollbar-track-color: #222222; scrollbar-arrow-color: #222222">
<div id="tags" style="position:relative; left:5px; top:5px; visibility: hidden;">
		<table width="240">
        <tr>
        <td colspan="2" width="150">
        <b>Videos</b><br/>
        </td>
        </tr>
		{% for bas in dicts.items %}
		{% if bas.0.id == basket.id %}
		{% for video in bas.1 %}
		<tr>
        <td>
        <a href="/video/{{video.film.id}}/">{{video.film.text}}</a>
        </td>
        <td>
		<a onclick="return confirm('Remove {{video.film.text}} from te basket?');" href="/user/basket/video/delete/{{video.id}}/">
			<img src="/site_media/img/trash.gif"/>
		</a><br/>
        </td>
        </tr>
		{% endfor %}
		{% endif %}
		{% endfor %}
        </table>
	</div>
</div>	

</div>


{% endblock %}
